﻿
@{
    ViewBag.Title = "RK";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var listColumns = ViewBag.Columns as List<SGArchiveSystem7x.Models.CColumnsModel>;
}

<table id="Insiders_BrrHistory_grid" class="easyui-datagrid" style="width:100%;" title="@ViewBag.NAME" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:true,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Insiders_BrrHistory_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead frozen="true">
        <tr>
            <th data-options="field:'ck',checkbox:true"></th>
            @{foreach (var c in listColumns)
                {
                    if (c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
    <thead>
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (!c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
</table>
<div id="Insiders_BrrHistory_tb" style="padding:2px 5px;">
    <select id="Insiders_BrrHistory_cmbArchiveTree" class="easyui-combobox" labelposition="right" label="档案类型：" data-options="editable:false" name="Insiders_BrrHistory_cmbType" style="width:170px;" panelHeight="auto" editable="false">
        <option value="-1">全部</option>
        @{
            foreach (SGArchiveSystem7xDB.T_ArchiveTree n in ViewBag.ArchiveTree)
            {
                <option value="@n.AR_NAME">@n.AR_NAME</option>
            }
        }
    </select>
    <input type="text" class="easyui-textbox pull-left" label="档号:" labelwidth="40px" labelalign="right" style="width:180px" id="ArchiveInit_ArchiveAJ_txtQueryDH" />
    <input type="text" class="easyui-textbox pull-left" label="年度:" labelwidth="40px" labelalign="right" style="width:100px" id="ArchiveInit_ArchiveAJ_txtQueryND" />
    <input type="text" class="easyui-textbox pull-left" label="题名:" labelwidth="40px" labelalign="right" style="width:230px" id="ArchiveInit_ArchiveAJ_txtQueryTM" />
    <a href="javascript:void(0);" class="easyui-linkbutton button-blue" iconCls="icon-search" onclick="QUERY()" style="height: 30px;width:100px">查询</a>
    <a href="javascript:void(0);" class="easyui-linkbutton button-orange" iconCls="icon-ok" onclick="RK()" style="height: 30px;width:100px">人工归库</a>
</div>
<script>
    $(document).ready(function () {
        $('#Insiders_BrrHistory_grid').datagrid({
            url: '/NoSQ/Get_ajaxRK',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
        InitPagenation();
    });


    function SearchPager(num, size) {

        $('#Insiders_BrrHistory_grid').datagrid('options').url = '/Insiders/Get_ajaxRKPager?num=' + num +
            '&size=' + size;
        $('#Insiders_BrrHistory_grid').datagrid('reload');
        $('#Insiders_BrrHistory_grid').datagrid('options').pageNumber = num;
        $('#Insiders_BrrHistory_grid').datagrid('options').pageSize = size;
    }


    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#Insiders_BrrHistory_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                SearchPager(pageNumber, pageSize);
            }
        });
    }
    function QUERY() {
        var type = $('#Insiders_BrrHistory_cmbArchiveTree').combobox('getValue');
        var dh = $('#ArchiveInit_ArchiveAJ_txtQueryDH').val();
        var tm = $('#ArchiveInit_ArchiveAJ_txtQueryTM').val();
        var nd = $('#ArchiveInit_ArchiveAJ_txtQueryND').val();
        //string arname, string dh, string tm, string nd
         $('#Insiders_BrrHistory_grid').datagrid({
             url: '/NoSQ/Get_ajaxRK?arname=' + type + '&dh=' + dh + '&tm=' + tm + '&nd=' + nd,
             singleSelect: true,
             method: 'post',
             onLoadSuccess: function (data) {
                 $('.pagination-page-list').hide();
             }
        });
        InitPagenation();
    }
    function formatDate(value, row) {
        if (value != null) {
            var time = new Date(parseInt(value.substr(6, 19)))//.toLocaleDateString();//13
            return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
        }
        else {
            return "";
        }
    }
    function formatKFZT(value, row) {
        if (value == "1")
            return "<span style='color:blue'>在库</span>";
        else if (value == "2")
            return "<span style='color:red'>等待出库</span>";
        else if (value == "3")
            return "<span style='color:red'>借出</span>";
        else
            return "<span style='color:red'>已销毁</span>";
    }
    function formatAJZT(value, row) {
        if (value == "1")
            return "<span style='color:blue'>正常</span>";
        else if (value == "0")
            return "<span style='color:red'>未授权</span>";
        else if (value == "2")
            return "<span style='color:red'>未授权(已处理)</span>";
    }
    function InitPagenation() {
        //设置分页控件
        var p = $('#Insiders_BrrHistory_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                SearchPager(pageNumber, pageSize);
            }
        });
    }

    ///刷新页面
    function UploadList() {
        SearchPager($('#Insiders_BrrHistory_grid').datagrid('options').pageNumber, $('#Insiders_BrrHistory_grid').datagrid('options').pageSize);
    }

    function RK() {
        var rows = $('#Insiders_BrrHistory_grid').datagrid('getChecked');
        if (rows.length == 0) {
            $.messager.alert('提示！', '请选择您要的手动入库的档案!', 'info');
            return false;
        }

        for (var i = 0; i < rows.length; i++) {
            if (rows[i].AJZT == '0') {
                $.messager.alert('提示！', '有档案还有未处理的非授权信息，请先处理后再手动入库!', 'info');
                return false;
            }
        }

        var strs = '';
        $.messager.confirm("提示", "确定要将选择的档案手动入库吗？", function (r) {
            if (r) {
                for (i = 0; i < rows.length; i++) {
                    strs += rows[i].ID + ',';
                }
                ///alert(data);
                $.ajax({
                    url: "/NoSQ/Set_ajaxHandRK",
                    dataType: "text",
                    type: "post",
                    data: { 'ids': strs},
                    success: function (data) {
                        if (data == "1") {
                            $.messager.alert('提示！', '处理完成!', 'info');
                            QUERY();
                        }
                        else { $.messager.alert('提示！', '处理失败!', 'error'); }
                    }
                });
            }
        });


    }
</script>



